/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.apache.abdera.parser.stax;

import com.appspot.trafficando.util.AtomHelper;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Serializable;
import java.io.StringWriter;
import org.apache.abdera.model.Entry;
import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMFactory;

/**
 *
 * @author Domenico Maria Giffone
 */
public class SerializableFOMEntry extends FOMEntry implements Serializable {

    private static final long serialVersionUID = 1L;

    public SerializableFOMEntry(OMContainer doc, OMFactory factory) {
        super(doc, factory);
    }

    private void writeObject(java.io.ObjectOutputStream out)
            throws IOException {
        StringWriter sw = new StringWriter();
        this.writeTo(sw);
        out.writeBytes(sw.toString());
        out.flush();
        out.close();
    }

    private void readObject(java.io.ObjectInputStream in)
            throws IOException, ClassNotFoundException {
        Reader bf = new BufferedReader(new InputStreamReader(in));
        final Entry deserialized = (Entry) AtomHelper.getParser().parse(bf).getRoot();
        AtomHelper.copyEntry(deserialized, this);
        bf.close();
        in.close();
    }

    // DEBUG

   /* @Override
    public Entry addCategory(Category category) {
        System.err.println("addCategory(Category category) " + category);
        return super.addCategory(category);
    }

    @Override
    public Category addCategory(String term) {
        System.err.println("addCategory(String term) " + term);
        return super.addCategory(term);
    }

    @Override
    public Category addCategory(String scheme, String term, String label) {
        System.err.println("addCategory(String scheme, String term, String label) " + scheme + ", " + term + ", " + label);
        return super.addCategory(scheme, term, label);
    }

    @Override
    public List<Category> getCategories() {
        System.err.println("getCategories() ");
        return super.getCategories();
    }

    @Override
    public List<Category> getCategories(String scheme) {
        System.err.println("getCategories(String scheme) " + scheme);
        return super.getCategories(scheme);
    } */


}
